<?php

Raise::load('core.RaiseFile');

/**
 *TestCoreRaiseFile
 * Testing unit of 'phpraise/core/RaiseFile.php'
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseFile extends RaiseTest {
    public static function testFile(){

        self::assertClassExists('RaiseFile');
        self::assertClassExtends('RaiseFile', 'RaiseObject');

        $file = new RaiseFile('testFile.raise');
        self::assertObjectClass($file, 'RaiseFile');
        self::assertFileNotExist($file->getPathName());
        $file->createFile();
        self::assertFileExist($file->getPathName());

        $s = 'testing file content';
        $file->setContent($s);
        self::assertStrictEqual($file->getContent(), $s);

        self::assertStrictEqual($file->size(), strlen($s));

        self::assertStrictEqual($file->getFileName(), basename($file->getPathName()));

        self::assertStrictEqual($file->getHash(), sha1_file($file->getPathName()));

        $file->delete();
        self::assertFileNotExist($file->getPathName());

    }
}

